package com.wdj.creation.singleton.staticfactory;

/**
 * @ClassName Singleton
 * @Description  通过静态方法
 * @Author wdj
 * @Date 2020/8/20 22:55
 * @Version 1.0
 **/
public class Singleton {
    private static Singleton str = null;

    private Singleton(){}
    public static Singleton getInstance(){
        if(str == null){
            str = new Singleton();
        }
        return str;
    }

    public static void main(String[] args) {
        Singleton singleton1 = Singleton.getInstance();
        Singleton singleton2 = Singleton.getInstance();
        System.out.println(singleton1 == singleton2);
        System.out.println(singleton1.equals(singleton2));

    }
}
